;
(function($) {
    var scroll_container = {};
    var methods = {
        set: function(options) {
            var setting = JSON.parse($(this).attr("setting"));
            setting = $.extend(setting, options);
            $(this).attr("setting", JSON.stringify(setting));
            return $(this);
        },
        config: function() {
            return JSON.parse($(this).attr("setting"));
        },
        init: function(options) {
            var setting = {
                before: null, //表格渲染初始化之前
                after: null, //表格渲染初始化完毕后
                hidden_column: [], //初始化默认隐藏列
                use_foot: false
            };
            setting = $.extend(setting, options);

            var $this = $(this);
            if ($this.length == 0)
                return;
            if ($.isFunction(setting.before)) {
                setting.before();
            }

            if (setting.hidden_column.length > 0) {
                $this.each(function() {
                    $(this).wmpDetail("hidden_column", setting.hidden_column);
                });
            }

            $this.each(function () {
                var $thisItem = $(this);
                $thisItem.find(".ckeckAll").click(function () {
                    if ($(this).find("a").hasClass("checked")) {
                        $(this).find("a").removeClass("checked");
                    } else {
                        $(this).find("a").addClass("checked");
                    }
                    if ($(this).find("a").hasClass("checked")) {
                        $thisItem.find(".ckeckItem a").addClass("checked");
                    } else {
                        $thisItem.find(".ckeckItem a").removeClass("checked");
                    }
                });
                $thisItem.on("click", ".ckeckItem", function () {
                    if ($(this).find("a").hasClass("checked")) {
                        $thisItem.find("a").removeClass("checked");
                    } else {
                        $thisItem.find("a").addClass("checked");
                    }
                });
                $(this).attr("setting", JSON.stringify(setting));

                if ($(this).is(":visible")) {
                    $(this).find("table thead th").each(function() {
                        if (!$(this).is(":visible")) {
                            $(this).attr("hidden", "hidden");
                        }
                    });
                }

                $(this).wmpDetail("hidden_auto");

                $(this).wmpDetail("empty");
            });

            if ($.isFunction(setting.after)) {
                setting.after();
            }
        },
        tmpl: function() {
            var $this = $(this);
            var $tpl = $this.find("script[type=\"text/x-jquery-tmpl\"]");
            if ($tpl.length == 0) {
                //alert("明细缺少模版数据"); 
                alert("明细缺少模版数据");
                return;
            }
            return $tpl.attr("id");
        },
        th_con: function() {
            var $table = $(this).find("table");
            var $thead_th = $table.find("thead tr th");
            var filed_data = {};
            $thead_th.each(function() {
                filed_data[$(this).attr("filed")] = $(this).html();
            });
            return filed_data;
        },///初始化控件
        rendercontrol: function (rowobj) {
            var $this = $(this);
            if (rowobj != undefined)
                $this = rowobj;

            if ($("tr#" + $this.attr("id")).length > 0) {
                $this = $("tr#" + $this.attr("id"));
            }
            if ($this.find("[controltype=select]").WmpSelect) {
                $this.find("[controltype=multuser]").WmpSelect("user", { multy: true }); //初始化 多选用户
                $this.find("[controltype=user]").WmpSelect("user"); //初始化 单选用户
                $this.find("[controltype=dept]").WmpSelect("dept"); //初始化 单选部门
                $this.find("[controltype=cost]").WmpSelect("cost"); //初始化 选成本中心
                $this.find("[controltype=project]").WmpSelect("project"); //初始化 选项目中心
            }
            if ($this.find("[controltype=select]").WmpSelectBox) {
                $this.find("[controltype=select]").each(function () {
                    var setting = {};
                    switch ($(this).attr("EditType")) {
                        case "Single": setting.multy = false; break;
                        case "Multi": setting.multy = true; break;
                        case "SingleQuery": setting.multy = false; setting.search = true; break;
                        case "MultiQuery": setting.multy = true; setting.search = true; break;
                        default: setting.multy = false; break;
                    }
                    $(this).WmpSelectBox("init", setting);
                    var selectvalue=$(this).attr("selectvalue");
                    if (selectvalue != undefined && selectvalue != "" && selectvalue != null) {
                        $(this).WmpSelectBox("set", selectvalue);
                    }
                });
            }
          ///  $this.find("[controltype=select]").WmpSelectpicker("init");
            if ($this.find("[controltype=time]").wmpDate)
                $this.find("[controltype=time]").wmpDate("calendar", {});
            if ($this.find("[controltype=time]").wmpDate)
            $this.find("[controltype=singletime]").wmpDate("time", {});//前面的人把time用于日期格式了，没办法我现在只能用一个singletime（单纯的时间）
            ///////////多选按钮绑定默认值
            $this.find("[type=checkboxlist]").each(function () {
                $(this).find(".container-radio").on("click", function () {
                    if ($(this).parent("[type=checkboxlist]").attr("disabled") != "disabled") {
                        if ($(this).find("a").hasClass("checked")) {
                            $(this).find("a").removeClass("checked");
                        } else {
                            $(this).find("a").addClass("checked");
                        }
                    }
                });
                var selectValue = $(this).attr("selectValue");
                if (selectValue != "" && selectValue != undefined) {
                    $(this).find("a").removeClass("checked");
                    if (selectValue != "") {
                        var arryValue = selectValue.split(';');
                        for (var str in arryValue) {
                            if (str != "") {
                                $(this).find("[value=" + str + "]").addClass("checked");
                            }
                        }
                    }
                }
            });
            $this.find("[type=radiolist]").each(function () {
                $(this).find(" .container-radio").on("click", function () {
                    if ($(this).parent().attr("disabled") != "disabled") {
                        $(this).siblings().find("a").removeClass("checked");
                        $(this).find("a").addClass("checked");
                    }
                });
                var selectValue = $(this).attr("selectValue");
                if (selectValue != "" && selectValue != undefined) {
                    $(this).find("a").removeClass("checked");
                    if (selectValue != "") {
                        $(this).find("[value=" + selectValue + "]").addClass("checked");
                    }
                }
            })
         
            //$this.find("[type=checkboxlist][selectValue]").each(function () {
            //    var selectValue = $(this).attr("selectValue");
            //    $(this).find("a").removeClass("checked");
            //    if (selectValue != "") {
            //        var arryValue=selectValue.split(';');
            //        for (var str in arryValue) {
            //            if (str != "") {
            //                $(this).find("[value=" + str + "]").addClass("checked");
            //            }
            //        }
            //    }
            //});
            ///////////单选按钮绑定默认值
            //$this.find("[type=radioList][selectValue]").each(function () {
            //    var selectValue = $(this).attr("selectValue");
            //    $(this).find("a").removeClass("checked");
            //    if (selectValue != "") {
            //        $(this).find("[value=" + selectValue + "]").addClass("checked");
            //    }
            //});
            var calendarSelector = $(this);
            if (calendarSelector.attr("initContorl") != "" && calendarSelector.attr("initContorl") != undefined) {
                var initContorl = null;
                eval("initContorl=" +calendarSelector.attr("initContorl"));
                if ($.isFunction(initContorl)) {
                    initContorl($this);
                }
            }
       }, ///控件进行赋值
        controlAssignment: function() {
            if ($(this).find("[filedName]").length == 0)
                return;
            $(this).find("[tr_json_val]").each(function() {
                var rowdata = JSON.parse(decodeURI($(this).attr("tr_json_val")))
                $(this).find("[filedName]").each(function() {
                    var filedName = $(this).attr("filedName");
                    var controltype = $(this).attr("controltype");
                    var filedvalue = "";
                    switch (controltype) {
                        case "multuser":
                        case "user":
                            filedvalue = "";
                        case "dept":
                            filedvalue = "";
                            var selectorList = $(this).WmpSelect("get");
                            for (var idex = 0; idex < selectorList.length; idex++) {
                                filedvalue = filedvalue == "" ? selectorList[idex].no : filedvalue + ";" + selectorList[idex].no;
                            }
                            break;
                        case "cost":
                        case "project":
                            filedvalue = encodeURIComponent(JSON.stringify($("#" + $(this).attr("id")).WmpSelect("get")));
                            break;
                        case "select":
                            filedvalue = $(this).WmpSelectBox("getvalue");
                            break;
                        case "time":
                            filedvalue = $(this).val();
                            break;
                        case "singletime":
                            filedvalue = $(this).val();
                            break;
                        default:
                            var typestr = $(this).attr("type") == undefined ? $(this)[0].tagName.toLowerCase() : $(this).attr("type").toLowerCase();
                            switch (typestr) {
                                case "hidden":
                                case "textarea":
                                case "text":
                                case "number":
                                case "email":
                                case "month":
                                case "url":
                                case "button":
                                    filedvalue = $(this).val();
                                    break;
                                case "select":
                                    filedvalue = $(this).WmpSelectBox("getvalue");
                                    break;
                                case "checkbox":
                                    filedvalue =$("[filedName="+$(this).attr("filedName")+"]:checked").val() ;
                                    break;
                                case "radiolist":
                                    filedvalue = $(this).find("a.checked").attr("value");
                                    break;
                                case "checkboxlist":
                                    filedvalue = "";
                                    $(this).find("a.checked").each(function () {
                                        filedvalue = filedvalue == "" ? $(this).attr("value") : filedvalue + ";" + $(this).attr("value");
                                    });
                                    break;
                                default:
                                    filedvalue = $(this).text();
                                    break;
                            }
                            break;
                    }
                    rowdata[filedName] = filedvalue;
                });
                $(this).attr("tr_json_val", encodeURI(JSON.stringify(rowdata)))
            });
        },
        rowControlAssignment: function(rowobj) {
            if ($(rowobj).attr("tr_json_val") == undefined || $(rowobj).find("[filedName]").length == 0)
                return;
            var rowdata = JSON.parse(decodeURI($(rowobj).attr("tr_json_val")))
            $(rowobj).find("[filedName]").each(function() {
                var filedName = $(this).attr("filedName");
                var controltype = $(this).attr("controltype");
                var filedvalue = "";
                switch (controltype) {
                    case "multuser":
                    case "user":
                    case "dept":
                        filedvalue = "";
                        var selectorList = $(this).WmpSelect("get");
                        for (var idex = 0; idex < selectorList.length; idex++) {
                            filedvalue = filedvalue == "" ? selectorList[idex].no : filedvalue + ";" + selectorList[idex].no;
                        }
                        break;

                    case "cost":
                    case "project":
                        filedvalue = encodeURIComponent(JSON.stringify($("#" + $(this).attr("id")).WmpSelect("get")));
                        break;
                    case "select":
                        filedvalue = $(this).WmpSelectBox("getvalue");
                        break;
                    case "time":
                        filedvalue = $(this).val();
                        break;
                    case "singletime":
                        filedvalue = $(this).val();
                        break;
                    default:
                        var typestr = $(this).attr("type") == undefined ? $(this)[0].tagName.toLowerCase() : $(this).attr("type").toLowerCase();
                        switch (typestr) {
                            case "hidden":
                            case "textarea":
                            case "text":
                            case "number":
                            case "email":
                            case "month":
                            case "url":
                            case "button":
                                filedvalue = $(this).val();
                                break;
                            case "select":
                                filedvalue = $(this).WmpSelectBox("getvalue");
                                break;
                            case "checkbox":
                                filedvalue = $("[filedName=" + $(this).attr("filedName") + "]:checked").val();
                                break;
                            case "radiolist":
                                filedvalue = $(this).find("a.checked").attr("value");
                                break;
                            case "checkboxlist":
                                filedvalue = "";
                                $(this).find("a.checked").each(function () {
                                    filedvalue = filedvalue == "" ? $(this).attr("value") : filedvalue + ";" + $(this).attr("value");
                                });
                                break;
                            default:
                                filedvalue = $(this).text();
                                break;
                        }
                        break;
                }
                rowdata[filedName] = filedvalue;
            });
            $(rowobj).attr("tr_json_val", encodeURI(JSON.stringify(rowdata)))
        },
        scroll: function () {
            var $this = $(this);
            if ($(window).width() > 768) {
                $this.each(function (index, item) {
                    if ($(this).find(".scroll_wrapper").length > 0) {
                        $(this).find(".scroll_wrapper").attr("class", "");
                        $(this).find(".scroll_scroller").attr("class", "");
                    }
                });
                return;
            }

            if ($.query.get("OperateType") == "Print") {
                return;
            }
            $this.each(function (index, item) {
                var $item = $(this);
                var table_container = $item.find("div.detail-table");
                var $table = $item.find("table");
                var type = $table.attr("data-type");

                var detail_id = $item.attr("id");
                if (scroll_container[detail_id]) {
                    if ($(window).width() > 768) {
                        $item.find("div.scroll_scroller").css({
                            "width": "auto"
                        });
                    }
                }

                var width = 0;

                if (type == "table") {
                    var theadLastTr = $table.find("thead:first tr").first();
                    theadLastTr.find("th:visible").each(function () {
                        width += $(this).outerWidth(true);
                    });
                }

                var window_width = $(window).width();
                if (isIE()) {
                    window_width = window_width - 15 - 5;
                }

                if (window_width >= width) {

                    $item.find("div.detail-title i.arrow_gun").remove()

                    if (scroll_container[detail_id]) {
                        scroll_container[detail_id].scrollTo(0, 0, 100);
                        scroll_container[detail_id].destroy();
                        scroll_container[detail_id] = null;
                    }
                    return;
                } else {
                    if ($item.attr("type") == "datalist" && $item.find("div.detail-title i.arrow_gun").length == 0) {
                        $item.find("div.detail-title").append("<i class=\"arrow_gun\" title='Drag item to view'></i>");
                    }
                }

                if (!scroll_container[detail_id]) {
                    if (table_container.find("div.scroll_wrapper").length > 0) {
                        table_container.find("div.scroll_scroller").css("width", width + "px");
                    } else {
                        var scroll_width = "style='width:" + width + "px;'";
                        var table_html = table_container.html();
                        var scroll_wrapper = $("<div class=\"scroll_wrapper\" id=\"scroller_" + detail_id + "\" />");
                        var scroll_scroller = $("<div class=\"scroll_scroller\" " + scroll_width + " />");
                        table_container.html(scroll_wrapper.append(scroll_scroller.append(table_html)));
                    }

                    var scroll_object = table_container.find("div.scroll_wrapper").attr("id");
                    scroll_container[detail_id] = new IScroll("#" + scroll_object, {
                        preventDefault: false,
                        scrollbars: true,
                        fadeScrollbars: true,
                        interactiveScrollbars: true,
                        scrollX: true,
                        scrollY: false,
                        click: false,
                        mouseWheel: false
                    });

                    scroll_container[detail_id].on("scrollEnd", function () {
                        $('input').toggleClass('force-redraw');
                    });
                } else {
                    table_container.find("div.scroll_scroller").css("width", width + "px");
                    scroll_container[detail_id].scrollTo(0, 0, 100);

                    setTimeout(function () {
                        if (scroll_container[detail_id]) {
                            scroll_container[detail_id].refresh();
                        }
                    }, 100);
                }
            });
        },
        empty: function() {
            var $this = $(this);
            $this.each(function() {
                $(this).find("table tbody").html("");

                var config = $(this).attr("setting") == undefined ? {} : JSON.parse($(this).attr("setting"));
                if (config.use_foot || (!config.use_foot && $(this).find("table tfoot").length > 0)) {
                    /*存在自定义的tfoot,则不填充默认为空信息的tfoot*/
                    $(this).wmpDetail("scroll");
                    return;
                }

                var col_length = $(this).find("th").length;
                var align = "";
                if ($(window).width() < 768) {
                    align = "style='text-align:left;'";
                } else {
                    align = "style='text-align:center;'";
                }

                var empty_html = "<tr><td colspan=\"" + col_length + "\" " + align + ">" + window.LangMsg['msg_wmp_no_detail_data'] + "</td></tr>";
                var $tfoot = $(this).find("tfoot");
                if ($tfoot.length > 0) {
                    $tfoot.html(empty_html);
                } else {
                    $(this).find("table").append($("<tfoot/>").append(empty_html));
                }
                $(this).find("table thead").show();
                $(this).wmpDetail("scroll");
            });
            return $this;
        },
        reset_index: function() {
            var $this = $(this);

            $this.each(function() {
                var $table = $(this).find("table");
                var $sort = $(this).find("table tbody tr td[filed=\"index\"]");
                var type = $table.attr("data-type");

                if (type == "list") {
                    $sort = $table.find("tr td div[filed=\"index\"] div.list-content span");
                }

                $sort.each(function(index, item) {
                    $(this).html(index + 1);
                });

                $(this).wmpDetail("hidden_auto")
            });
            return $this;
        },
        hidden_column: function(data) {
            if (data.length == 0) {
                return;
            }
            var $this = $(this);

            $this.each(function() {
                var $item = $(this);
                var $table = $item.find("table");
                var type = $table.attr("data-type");
                var $thread_tr = $item.find("table thead tr");
                var $tbody_tr = $item.find("table tbody tr");
                var $tfoot_tr = $item.find("table tfoot tr");

                if (type == "table") {
                    for (var start = 0; start < data.length; start++) {
                        $tbody_tr.find("td[filed='" + data[start] + "']").hide();
                        $thread_tr.find("th[filed='" + data[start] + "']").hide().attr("hidden", "hidden");
                        if ($tfoot_tr != undefined && $tfoot_tr.length > 0) {
                            $tfoot_tr.find("td[filed='" + data[start] + "']").hide();
                        }
                    }
                } else {
                    for (var start = 0; start < data.length; start++) {
                        $tbody_tr.find("td div[filed='" + data[start] + "']").hide();
                        $thread_tr.find("th[filed='" + data[start] + "']").hide().attr("hidden", "hidden");
                        if ($tfoot_tr != undefined && $tfoot_tr.length > 0) {
                            $tfoot_tr.find("td[filed='" + data[start] + "']").hide();
                        }
                    }
                }

                $item.wmpDetail("scroll");
            });

            return $this;
        },
        hidden_auto: function() {
            var $this = $(this);

            $this.each(function() {
                var $item = $(this);
                var $table = $item.find("table");
                var type = $table.attr("data-type");
                var hidden_data = [];
                var hid_th = $table.find("thead th[hidden='hidden']");
                if (hid_th.length == 0) {
                    $item.wmpDetail("scroll");
                    return;
                }

                hid_th.each(function(index, item) {
                    hidden_data.push($(item).attr("filed"));
                });

                $item.wmpDetail("hidden_column", hidden_data);
                $item.wmpDetail("readonly_column");
            });

            return $this;
        },
        readonly_column: function (data, rowsobj) {
            var $this = $(this);
            var $thisRows = typeof (rowsobj) == "undefined" ? $(this).find("[tr_json_val]") : rowsobj;
            if (typeof (data) != "undefined") {
                $this.find("thead th[readonly]").removeAttr("readonly");
                $(data).each(function () {
                    $this.find("thead th[filed=" + this + "]").attr("readonly", "readonly");
                });
            }
            $thisRows.each(function () {
                $(this).find("[controltype]").each(function () {
                    var filedname = $(this).parents("td").attr("filed");
                    if ($this.find("thead th[filed=" + filedname + "]").attr("readonly") == "readonly") {
                        var controltype = $(this).attr("controltype");
                        var filedvalue = "";
                        switch (controltype) {
                            case "multuser":
                            case "user":
                            case "dept":
                            case "project":
                            case "cost":
                                $(this).attr("disabled", "disabled");
                                break;
                            case "select": 
                                $(this).WmpSelectBox("readonly") ;
                                break;
                            case "time":
                                $(this).attr("disabled", "disabled");
                                break;
                            case "singletime":
                                $(this).attr("disabled", "disabled");
                                break;
                        }
                    }
                    if ($this.find("thead th[filed=" + filedname + "]").attr("hidden") == "hidden") {
                        $(this).parents("td").hide();
                    }
                });
                $(this).find("[type]").each(function () {
                    var filedname = $(this).parents("td").attr("filed");
                    if ($this.find("thead th[filed=" + filedname + "]").attr("readonly") == "readonly") {
                        var typestr = $(this).attr("type") == undefined ? $(this)[0].tagName.toLowerCase() : $(this).attr("type").toLowerCase();
                        switch (typestr) {
                            case "textarea":
                            case "text":
                            case "number":
                            case "email":
                            case "month":
                            case "url": if (!$(this).is(':hidden')) { $(this).attr("disabled", "disabled"); }
                                break;
                            case "select":
                                if (!$(this).is(':hidden')) { $(this).WmpSelectBox("readonly") ; }
                                break;
                            default:
                                $(this).attr("disabled", "disabled");
                                break;
                        }
                    }
                    
                });
            });

            return $this;
        },
        add_row: function(data,row_object) {
            if (!data) {
                return;
            }

            var data_object = [];
            if (!data.length) {
                data_object.push(data);
            } else {
                data_object = data;
            }

            var $this = $(this);
            var $table = $this.find("table");
            var type = $table.attr("data-type");
            var startIndex = $table.find("tbody tr").length;
            var config = $(this).attr("setting") == undefined ? {} : JSON.parse($(this).attr("setting"));
            if (!config.use_foot && $this.attr("use_foot") != "true") {
                $table.find("tfoot").remove();
            }
            var render_data = { rows: data_object };
            var render_html = "";
            var tpl_id = $this.wmpDetail("tmpl");
            if (type == "table") {
                render_html = $this.find("#" + tpl_id).tmpl(render_data);
            } 
            var addTrs = $(render_html).filter("tr");
            if ($(render_html).filter("[tr_json_val]").length == 0) {
                addTrs.each(function(index, item) {
                    $(this).attr("tr_json_val", encodeURI(JSON.stringify(data_object[index])));
                });
            }
            if(typeof(row_object)!="undefined"&&$(row_object)[0].tagName.toLowerCase()=="tr".toLowerCase()){
                $(row_object).after(addTrs);
            }else {
                $table.append(addTrs);
            }
            var endIndex = $table.find("tbody tr").length;
            $(this).wmpDetail("reset_index");
            ///解决第一行未渲染的问题

            if (startIndex == 0 && (endIndex - startIndex) == 1) {
                $(this).wmpDetail("rendercontrol");
            } else {
                $(this).wmpDetail("rendercontrol", addTrs);
                //for (var idex = startIndex; idex < endIndex; idex++) {
                //    var trobj = $table.find("tbody tr:eq(" + idex + ")");
                    
                //}
            }
            
            return $(this);
        },
        edit_row: function(row_object, data) {
            var $this = $(this);
            var $table = $this.find("table");
            var type = $table.attr("data-type");

            var old_val_json = $this.wmpDetail("get_row", row_object);
            var startindex = $(row_object).index();
            var endindex = $(row_object).index() + 1;
            var new_val_json = $.extend(old_val_json, data);
            var render_data = { rows: [new_val_json] };

            var tpl_id = $this.wmpDetail("tmpl");
            var render_html;
            if (type == "table") {
                render_html = $($this.find("#" + tpl_id).tmpl(render_data)).html();
            } else if (type == "list") {
                render_html = $($this.find("#" + tpl_id + "-1").tmpl(render_data)).html();
            }
            var addTrs = $(render_html).filter("tr");
            row_object.html(render_html);
            row_object.attr("tr_json_val", encodeURI(JSON.stringify(new_val_json)));
            $(this).wmpDetail("reset_index");
            for (var idex = startindex; idex < endindex; idex++) {
                var trobj = $table.find("tbody tr:eq(" + idex + ")");
                $(this).wmpDetail("rendercontrol", trobj);
            }
            return $(this);
        },
        remove_row: function(row_object) {
            var $this = $(this);
            row_object.remove();

            var $table = $this.find("table");
            if ($table.find("tbody tr").length == 0) {
                $this.wmpDetail("empty");
            } else {
                $this.wmpDetail("reset_index");
            }
            return $this;
        },
        get_row: function(row_object) {
            $(this).wmpDetail("rowControlAssignment", row_object);
            var tr_json = row_object.attr("tr_json_val");
            return JSON.parse(decodeURI(tr_json));
        },
        get: function() {
            var data = [];
            var $tr = $(this).find("table tbody tr");
            if ($tr.length == 0) {
                return data;
            }
            var $this = $(this);
            $tr.each(function() {
                if ($(this).attr("tr_json_val") != undefined) {
                    $this.wmpDetail("rowControlAssignment", $(this));
                    data.push(JSON.parse(decodeURI($(this).attr("tr_json_val"))));
                }
            });

            return data;
        },
        readonly: function() {
            var $this = $(this);
            $this.wmpDetail("hidden_column", ["opration", "Opration"]);
            $this.find("div.detail-button button").hide();
            $(this).find("a").unbind("click");
            $(this).find("[tr_json_val]").each(function() {
                //var rowdata = JSON.parse(decodeURI($(this).attr("tr_json_val")))
                $(this).find("[controltype]").each(function() {
                    var controltype = $(this).attr("controltype");
                    var filedvalue = "";
                    switch (controltype) {
                        case "multuser":
                        case "user":
                        case "dept":
                        case "project":
                        case "cost":
                            $(this).WmpSelect("readonly");
                            break;
                        case "select":
                            $(this).WmpSelectBox("readonly");
                            break;
                        case "time":
                            $(this).parents("td").text($(this).val());
                            break;
                        case "singletime":
                            $(this).parents("td").text($(this).val());
                            break;
                    }
                });
                $(this).find("[type]").each(function() {
                    var typestr = $(this).attr("type") == undefined ? $(this)[0].tagName.toLowerCase() : $(this).attr("type").toLowerCase();
                    switch (typestr) {
                        case "textarea":
                        case "text":
                        case "number":
                        case "email":
                        case "month":
                        case "url": if (!$(this).is(':hidden')) $(this).parents("td").text($(this).val());
                            break;
                        case "select":
                            if (!$(this).is(':hidden')) $(this).WmpSelectBox("readonly");
                            break;
                        default:
                            filedvalue = $(this).text();
                            break;
                    }
                });
            });
            $(this).wmpDetail("scroll");
        }
    };
    $.fn.wmpDetail = function (method) {
            if (methods[method]) {
                return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
            } else if (typeof method === 'object' || !method) {
                return methods.init.apply(this, arguments);
            } else {
                $.error('Method' + method + 'does not exist');
            }
      
    };
})($);
